Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

131
Views
Discord.js | Add a role with a reaction

I've been on my discord bot for several days because I encountered a problem ...

I wanted to add the possibility of having a role following a reaction.

But it doesn't work as soon as I add the line to add the role, if I remove it it works fine.

code :

bot.on("messageReactionAdd", (reaction, member) => {

    if(reaction.message.id === "894623823855493171"){

        member.roles.add('892423129345978438');
        reaction.message.channel.send(`Tu as réagi : ✅ ${member}`);

    }
       
})
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

member is actually a User. The better way to do this is to get the GuildMember from the Guild. You can use GuildMemberManager.resolve

bot.on("messageReactionAdd", (reaction, user) => {
  if(reaction.message.id === "894623823855493171"){
    const member = reaction.guild.members.resolve(user)
    member.roles.add('892423129345978438');
    reaction.message.channel.send(`Tu as réagi : ✅ ${member}`);
  }
})
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!